home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 76 / DVD Actual 1 Marzo 2003.iso / Trial / TurboCAD 7.1 Pro / Data.Cab / F25226_SDKDemo.java < prev    next >
Encoding:
Java Source  |  2000-11-10  |  22.5 KB  |  780 lines

  1. /******************************************************************************/
  2. /**
  3.     International Microcomputer Software Inc. @1997 -- Rob Mayfield
  4.     This applet is a demonstration of the use of the IMSI SDK using Java.
  5.     It takes advantage of the Microsoft extension to Java using OLE.
  6.     It uses Microsoft's Variant class (com.ms.com.Variant) and connects
  7.     to the OLE server which can be either an inproc server (IMSIGX40.DLL) or
  8.     the local server (TCW40.EXE).
  9.     The main work for the SDK classes are done by the DrawingCanvas class
  10.     which handles the mouse action, repaint and calls which must interface to
  11.     the IMSI server.
  12.  
  13.     **** Must be run currently in Microsoft IExplorer or jview application viewer ****
  14.     to run:  jview SDKDemo.class
  15.  
  16.     ImageButton and VisualCafe by Symantec Corp. 1997
  17.     Ole and COM classes by Microsoft Corp. 1997
  18.  
  19.     version 1.0 March 31, 1997
  20. */
  21. /******************************************************************************/
  22.  
  23. import java.applet.*;
  24. import java.awt.*;
  25. import SDKDemoFrame;
  26. import DrawingCanvas;
  27. import mImageButton;
  28. import symantec.itools.awt.*;
  29.  
  30. /*
  31.     Main Class for applet SDKDemo
  32. */
  33. public class SDKDemo extends Applet
  34. {
  35.  
  36.     // main entry for application
  37.     public static void main(String args[])
  38.     {
  39.  
  40.         frame = new SDKDemoFrame("SDKDemo");
  41.  
  42.         // Must show Frame before we size it so insets() will return valid values
  43.         frame.show();
  44.         frame.hide();
  45.         frame.resize(frame.insets().left + frame.insets().right  + 619,
  46.                      frame.insets().top  + frame.insets().bottom + 514);
  47.  
  48.         //frame.resize(619, 514);
  49.  
  50.         SDKDemo appSDKDemo = new SDKDemo();
  51.  
  52.         frame.add("Center", appSDKDemo);
  53.         appSDKDemo.m_fStandAlone = true;
  54.         appSDKDemo.init();
  55.         
  56.         appSDKDemo.start();
  57.         frame.show();
  58.  
  59.     }
  60.  
  61.     // SDKDemo Class Constructor
  62.     public SDKDemo()
  63.     {
  64.     }
  65.  
  66.     void ComboBoxDrawings_Selected(Event event)
  67.     {
  68.         theDrawingCanvas.setButtonDown(NONECLICK);
  69.         notifyAllImageButtons(NONECLICK);
  70.  
  71.         // display selected item in combobox
  72.         String fName = ComboBoxDrawings.getSelectedItem();
  73.         if (fName != null)
  74.             fName = theDrawingCanvas.OpenDrawing(fName); // open the drawing and use SDK to paint on the canvas
  75.         // toggle all buttons to unclicked state
  76.     }
  77.  
  78.     void ButtonFindDrawings_Clicked(Event event)
  79.     {
  80.         if (event.modifiers == Event.META_MASK)
  81.         {    System.out.println("handleEvent: " + event.toString()); // this event never happens as regular right clicks on a button are xed
  82.         }
  83.         else
  84.         {
  85.             theDrawingCanvas.setButtonDown(NONECLICK);
  86.             notifyAllImageButtons(NONECLICK);  // set all buttons to up
  87.  
  88.             // find the drawing in file list, using SDK to load and display
  89.             String fName = theDrawingCanvas.OpenDrawing(null);
  90.             if (fName != null) ComboBoxDrawings.addItem(fName);
  91.             //ComboBoxDrawings.select();
  92.                //ComboBoxDrawings.reshape(220,8,252,21);  // if we don't put this reshape here the combobox will shrink to the size of the longest string
  93.         }
  94.     }
  95.  
  96.     void ButtonCursor_Action(Event event)
  97.     {
  98.         if (event.modifiers == Event.META_MASK)
  99.         {
  100.             String Str = helpStrings.General;
  101.  
  102.             (new ViewSourceDialog(frame, false, Str)).show();
  103.  
  104.         }
  105.         else
  106.         {
  107.             if (ButtonCursor.getBevelHeight() == 0)
  108.             {
  109.                 ButtonCursor.setBevelHeight(2);
  110.                 theDrawingCanvas.setButtonDown(NONECLICK);
  111.             }
  112.             else
  113.             {
  114.                 ButtonCursor.setBevelHeight(0);
  115.                 theDrawingCanvas.setButtonDown(PICKCLICK);
  116.             }
  117.  
  118.             notifyAllImageButtons(PICKCLICK);
  119.         }
  120.     }
  121.  
  122.     void ButtonStar_Action(Event event)
  123.     {
  124.  
  125.         if (ButtonStar.getBevelHeight() == 0)
  126.         {
  127.             theDrawingCanvas.setButtonDown(NONECLICK);
  128.             ButtonStar.setBevelHeight(2);
  129.         }
  130.         else
  131.         {
  132.             theDrawingCanvas.setButtonDown(STARCLICK);
  133.             ButtonStar.setBevelHeight(0);
  134.         }
  135.  
  136.         notifyAllImageButtons(STARCLICK);
  137.     }
  138.  
  139.     void ButtonSpline_Action(Event event)
  140.     {
  141.     
  142.         if (ButtonSpline.getBevelHeight() == 0)
  143.         {
  144.             theDrawingCanvas.setButtonDown(NONECLICK);
  145.             ButtonSpline.setBevelHeight(2);
  146.         }
  147.         else
  148.         {
  149.             theDrawingCanvas.setButtonDown(SPLINECLICK);
  150.             ButtonSpline.setBevelHeight(0);
  151.         }
  152.  
  153.         notifyAllImageButtons(SPLINECLICK);
  154.  
  155.     }
  156.  
  157.     void ButtonLine_Action(Event event)
  158.     {
  159.  
  160.         if (ButtonLine.getBevelHeight() == 0)
  161.         {
  162.             theDrawingCanvas.setButtonDown(NONECLICK);
  163.             ButtonLine.setBevelHeight(2);
  164.         }
  165.         else
  166.         {
  167.             theDrawingCanvas.setButtonDown(LINECLICK);
  168.             ButtonLine.setBevelHeight(0);
  169.         }
  170.  
  171.         notifyAllImageButtons(LINECLICK);
  172.     }
  173.  
  174.     void ButtonCircle_Action(Event event)
  175.     {
  176.         if (ButtonCircle.getBevelHeight() == 0)
  177.         {   ButtonCircle.setBevelHeight(2);   // set button to up state
  178.             theDrawingCanvas.setButtonDown(NONECLICK);
  179.         }
  180.         else  // click button and set it to 'down' state
  181.         {
  182.             theDrawingCanvas.setButtonDown(CIRCLECLICK);
  183.             ButtonCircle.setBevelHeight(0);
  184.         }
  185.  
  186.         notifyAllImageButtons(CIRCLECLICK);
  187.     }
  188.  
  189.     void ButtonProperties_Clicked(Event event)
  190.     {
  191.         theDrawingCanvas.displayProperties();
  192.         notifyAllImageButtons(NONECLICK);
  193.  
  194.     }
  195.  
  196.     void ButtonNew_Clicked(Event event)
  197.     {
  198.         //fName = theDrawingCanvas.OpenDrawing(fName);
  199.         theDrawingCanvas.NewDrawing();
  200.         theDrawingCanvas.setButtonDown(NONECLICK);
  201.         notifyAllImageButtons(NONECLICK);
  202.     }
  203.  
  204.     void ButtonZoomPlus_Clicked(Event event)
  205.     {
  206.         theDrawingCanvas.ZoomPlus();
  207.     }
  208.  
  209.     void ButtonZoomMinus_Clicked(Event event)
  210.     {
  211.         theDrawingCanvas.ZoomMinus();
  212.     }
  213.  
  214.     void verticalScrollbar_ScrollLineUp(Event event)
  215.     {
  216.         theDrawingCanvas.VScrollLineUp();
  217.     }
  218.     void verticalScrollbar_ScrollLineDown(Event event)
  219.     {
  220.         theDrawingCanvas.VScrollLineDown();
  221.     }
  222.     void verticalScrollbar_ScrollPageUp(Event event)
  223.     {
  224.         theDrawingCanvas.VScrollPageUp();
  225.     }
  226.     void verticalScrollbar_ScrollPageDown(Event event)
  227.     {
  228.         theDrawingCanvas.VScrollPageDown();
  229.  
  230.     }
  231.  
  232.     void horizontalScrollbar_ScrollLineUp(Event event)
  233.     {
  234.         theDrawingCanvas.HScrollLineUp();
  235.     }
  236.     void horizontalScrollbar_ScrollLineDown(Event event)
  237.     {
  238.         theDrawingCanvas.HScrollLineDown();
  239.     }
  240.     void horizontalScrollbar_ScrollPageUp(Event event)
  241.     {
  242.         theDrawingCanvas.HScrollPageUp();
  243.     }
  244.     void horizontalScrollbar_ScrollPageDown(Event event)
  245.     {
  246.         theDrawingCanvas.HScrollPageDown();
  247.  
  248.     }
  249.  
  250.  
  251.     public void notifyAllImageButtons(int From)
  252.     {   /*
  253.          This code simulates a group button set, where only one button is down
  254.          at one time and that button stays down until it is clicked again
  255.          or another in the group is clicked.
  256.         */
  257.         switch (From)
  258.         {   case CIRCLECLICK:
  259.                  ButtonLine.setBevelHeight(2);
  260.                  ButtonLine.repaint();
  261.  
  262.                  ButtonSpline.setBevelHeight(2);
  263.                  ButtonSpline.repaint();
  264.  
  265.                  ButtonStar.setBevelHeight(2);
  266.                  ButtonStar.repaint();
  267.  
  268.                  ButtonCursor.setBevelHeight(2);
  269.                  ButtonCursor.repaint();
  270.  
  271.                  ButtonCircle.repaint();
  272.                  break;
  273.  
  274.             case LINECLICK:
  275.                  ButtonCircle.setBevelHeight(2);
  276.                  ButtonCircle.repaint();
  277.  
  278.                  ButtonSpline.setBevelHeight(2);
  279.                  ButtonSpline.repaint();
  280.  
  281.                  ButtonStar.setBevelHeight(2);
  282.                  ButtonStar.repaint();
  283.  
  284.                  ButtonCursor.setBevelHeight(2);
  285.                  ButtonCursor.repaint();
  286.  
  287.                  ButtonLine.repaint();
  288.                  break;
  289.  
  290.             case SPLINECLICK:
  291.                  ButtonCircle.setBevelHeight(2);
  292.                  ButtonCircle.repaint();
  293.  
  294.                  ButtonLine.setBevelHeight(2);
  295.                  ButtonLine.repaint();
  296.  
  297.                  ButtonStar.setBevelHeight(2);
  298.                  ButtonStar.repaint();
  299.  
  300.                  ButtonCursor.setBevelHeight(2);
  301.                  ButtonCursor.repaint();
  302.  
  303.                  ButtonSpline.repaint();
  304.                  break;
  305.  
  306.             case STARCLICK:
  307.                  ButtonCircle.setBevelHeight(2);
  308.                  ButtonCircle.repaint();
  309.  
  310.                  ButtonLine.setBevelHeight(2);
  311.                  ButtonLine.repaint();
  312.  
  313.                  ButtonSpline.setBevelHeight(2);
  314.                  ButtonSpline.repaint();
  315.  
  316.                  ButtonCursor.setBevelHeight(2);
  317.                  ButtonCursor.repaint();
  318.  
  319.                  ButtonStar.repaint();
  320.                  break;
  321.  
  322.             case PICKCLICK:
  323.                  ButtonCircle.setBevelHeight(2);
  324.                  ButtonCircle.repaint();
  325.  
  326.                  ButtonLine.setBevelHeight(2);
  327.                  ButtonLine.repaint();
  328.  
  329.                  ButtonSpline.setBevelHeight(2);
  330.                  ButtonSpline.repaint();
  331.  
  332.                  ButtonStar.setBevelHeight(2);
  333.                  ButtonStar.repaint();
  334.  
  335.                  ButtonCursor.repaint();
  336.                  break;
  337.  
  338.             case NONECLICK:
  339.                  ButtonCircle.setBevelHeight(2);
  340.                  ButtonCircle.repaint();
  341.  
  342.                  ButtonLine.setBevelHeight(2);
  343.                  ButtonLine.repaint();
  344.  
  345.                  ButtonSpline.setBevelHeight(2);
  346.                  ButtonSpline.repaint();
  347.  
  348.                  ButtonStar.setBevelHeight(2);
  349.                  ButtonStar.repaint();
  350.  
  351.                  ButtonCursor.setBevelHeight(2);
  352.                  ButtonCursor.repaint();
  353.  
  354.                  break;
  355.  
  356.         }
  357.     }
  358.  
  359.     public boolean mouseDown(Event  evt, int  x, int  y)
  360.     {
  361.         if (evt.modifiers == Event.META_MASK)
  362.         {
  363.             // Create and show as not modal
  364.             (new ViewSourceDialog(frame, false, helpStrings.General)).show();
  365.             return true;
  366.         }
  367.         return false;
  368.     }
  369.  
  370.     public void init()
  371.     {
  372.         super.init();
  373.  
  374.         // We set no layout manager. We want exact placement (we could use GridBagLayout also, but it has redraw problems.).
  375.         setLayout(null);
  376.         //resize(619,514);  // set the applet size
  377.         // applet size come from frame
  378.         setBackground(new Color(0xC0C0C0));  // light gray color
  379.  
  380.     
  381.         // load the five image buttons. Here we use the Symantec ImageButton class
  382.         //ButtonCursor = new symantec.itools.awt.ImageButton();
  383.         ButtonCursor = new mImageButton();
  384.         ButtonCursor.reshape(483,34,26,24);
  385.         add(ButtonCursor);
  386.         ButtonCursor.setBevelHeight(2);
  387.  
  388.         // We need to find the base URL to find the images to load button images. In applet we use
  389.         // getDocumentBase(). In Frames we use the getProperty()
  390.         if (m_fStandAlone == true)
  391.             docBase = "file:///" + System.getProperty("user.dir").replace('\\', '/');
  392.         else
  393.             docBase = null;
  394.  
  395.         try
  396.         {
  397.             // load from the same URL base as applet or application
  398.             if (m_fStandAlone == true)
  399.             {
  400.                 ButtonCursor.setImageURL(new java.net.URL(docBase + "/cursor.gif"));
  401.             }
  402.             else
  403.             {
  404.                    ButtonCursor.setImageURL(new java.net.URL(getDocumentBase(), "./cursor.gif"));
  405.             }
  406.         }
  407.         catch (java.net.MalformedURLException error)
  408.         {
  409.             StatusBox.setText("error in URL");
  410.         }
  411.         ButtonCursor.setScaleMode(true);
  412.         ButtonStar = new mImageButton();
  413.         ButtonStar.reshape(440,34,26,24);
  414.         add(ButtonStar);
  415.         ButtonStar.setBevelHeight(2);
  416.         try
  417.         {
  418.             if (m_fStandAlone == true)
  419.             {
  420.                 ButtonStar.setImageURL(new java.net.URL(docBase + "/star.gif"));
  421.             }
  422.             else
  423.             {
  424.                    ButtonStar.setImageURL(new java.net.URL(getDocumentBase(), "./star.gif"));
  425.             }
  426.         }
  427.         catch (java.net.MalformedURLException error)
  428.         {
  429.             StatusBox.setText("error in URL");
  430.         }
  431.         ButtonStar.setScaleMode(true);
  432.         ButtonSpline = new mImageButton();
  433.         ButtonSpline.reshape(412,34,26,24);
  434.         add(ButtonSpline);
  435.         ButtonSpline.setBevelHeight(2);
  436.         try
  437.         {
  438.             if (m_fStandAlone == true)
  439.             {
  440.                 ButtonSpline.setImageURL(new java.net.URL(docBase + "/spline.gif"));
  441.             }
  442.             else
  443.             {
  444.                    ButtonSpline.setImageURL(new java.net.URL(getDocumentBase(), "./spline.gif"));
  445.             }
  446.         }
  447.         catch (java.net.MalformedURLException error)
  448.         {
  449.             StatusBox.setText("error in URL");
  450.         }
  451.         ButtonSpline.setScaleMode(true);
  452.         ButtonLine = new mImageButton();
  453.         ButtonLine.reshape(384,34,26,24);
  454.         add(ButtonLine);
  455.         ButtonLine.setBevelHeight(2);
  456.         try
  457.         {
  458.             if (m_fStandAlone == true)
  459.             {
  460.                 ButtonLine.setImageURL(new java.net.URL(docBase + "/line.gif"));
  461.             }
  462.             else
  463.             {
  464.                    ButtonLine.setImageURL(new java.net.URL(getDocumentBase(), "./line.gif"));
  465.             }
  466.         }
  467.         catch (java.net.MalformedURLException error)
  468.         {
  469.             StatusBox.setText("error in URL");
  470.         }
  471.         ButtonLine.setScaleMode(true);
  472.         ButtonCircle = new mImageButton();
  473.         ButtonCircle.reshape(356,34,26,24);
  474.         add(ButtonCircle);
  475.         ButtonCircle.setBevelHeight(2);
  476.         try
  477.         {
  478.             if (m_fStandAlone == true)
  479.             {
  480.                 ButtonCircle.setImageURL(new java.net.URL(docBase + "/circle.gif"));
  481.             }
  482.             else
  483.             {
  484.                    ButtonCircle.setImageURL(new java.net.URL(getDocumentBase(), "./circle.gif"));
  485.             }
  486.  
  487.         }
  488.         catch (java.net.MalformedURLException error)
  489.         {
  490.             StatusBox.setText("error in URL");
  491.         }
  492.         ButtonCircle.setScaleMode(true);  // set the buttton to scale the image to fit
  493.  
  494.         // put the other button on the applet
  495.         ButtonProperties = new java.awt.Button("Properties");
  496.         ButtonProperties.reshape(270,38,68,18);
  497.         add(ButtonProperties);
  498.         ButtonNew = new java.awt.Button("New");
  499.         ButtonNew.reshape(210,38,50,18);
  500.         add(ButtonNew);
  501.         ButtonZoomPlus = new java.awt.Button("Zoom +");
  502.         ButtonZoomPlus.reshape(150,38,50,18);
  503.         add(ButtonZoomPlus);
  504.         ButtonZoomMinus = new java.awt.Button("Zoom -");
  505.         ButtonZoomMinus.reshape(90,38,50,18);
  506.         add(ButtonZoomMinus);
  507.         ButtonFindDrawings = new java.awt.Button("Find Drawing");
  508.         ButtonFindDrawings.reshape(125,10,88,18);
  509.         add(ButtonFindDrawings);
  510.  
  511.         ComboBoxDrawings = new java.awt.Choice();
  512.         add(ComboBoxDrawings);
  513.         ComboBoxDrawings.reshape(220,8,252,21);
  514.  
  515.         /*
  516.            Add theDrawingCanvas to the form. This will be the active drawing
  517.            surface to which the IMSI SDK will interact. The DrawingCanvas class
  518.            is derived from Canvas and overides the paint and mouse events.
  519.         */
  520.         theDrawingCanvas = new DrawingCanvas(this);
  521.         theDrawingCanvas.reshape(7,68, bounds().width - 12, bounds().height - 105);  // 95
  522.         theDrawingCanvas.setBackground(new Color(0xFFFFFF));  // white background
  523.         add(theDrawingCanvas);
  524.  
  525.         // horizontal scroll bars
  526.         horizontalScrollbar = new java.awt.Scrollbar(Scrollbar.HORIZONTAL);
  527.         horizontalScrollbar.reshape(insets().left + 204,insets().top + 497,210,16);
  528.         horizontalScrollbar.setBackground(new Color(0xFFFFFF));
  529.         horizontalScrollbar.setValues(0, 1, 0, 100);
  530.         horizontalScrollbar.setLineIncrement(1);
  531.         horizontalScrollbar.setPageIncrement(10);
  532.         add(horizontalScrollbar);
  533.  
  534.         // verticle scroll bars
  535.         verticalScrollbar = new java.awt.Scrollbar(Scrollbar.VERTICAL);
  536.         verticalScrollbar.reshape(insets().left + 603,insets().top + 159,16,198);
  537.         verticalScrollbar.setBackground(new Color(0xFFFFFF));
  538.         verticalScrollbar.setValues(0, 1, 0, 100);
  539.         verticalScrollbar.setLineIncrement(1);
  540.         verticalScrollbar.setPageIncrement(10);
  541.         add(verticalScrollbar);
  542.  
  543.         StatusBox = new java.awt.TextField();
  544.         StatusBox.setEditable(false);
  545.         StatusBox.reshape(4, theDrawingCanvas.bounds().y + theDrawingCanvas.bounds().height + 2,
  546.             bounds().width - 8, 21);
  547.         add(StatusBox);
  548.  
  549.         frame.setParent(this);
  550.     }
  551.  
  552.     // Handle the events from the buttons and Combobox
  553.     public boolean handleEvent(Event event)
  554.     {
  555.         if (event.target == ButtonZoomMinus && event.id == Event.ACTION_EVENT)
  556.         {
  557.             ButtonZoomMinus_Clicked(event);
  558.             return true;
  559.         }
  560.         if (event.target == ButtonZoomPlus && event.id == Event.ACTION_EVENT)
  561.         {
  562.             ButtonZoomPlus_Clicked(event);
  563.             return true;
  564.         }
  565.         if (event.target == ButtonNew && event.id == Event.ACTION_EVENT)
  566.         {
  567.             ButtonNew_Clicked(event);
  568.             return true;
  569.         }
  570.         if (event.target == ButtonProperties && event.id == Event.ACTION_EVENT)
  571.         {
  572.             ButtonProperties_Clicked(event);
  573.             return true;
  574.         }
  575.         if (event.target == ButtonCircle && event.id == Event.ACTION_EVENT)
  576.         {
  577.             ButtonCircle_Action(event);
  578.             return true;
  579.         }
  580.         if (event.target == ButtonLine && event.id == Event.ACTION_EVENT)
  581.         {
  582.             ButtonLine_Action(event);
  583.             return true;
  584.         }
  585.         if (event.target == ButtonSpline && event.id == Event.ACTION_EVENT)
  586.         {
  587.             ButtonSpline_Action(event);
  588.             return true;
  589.         }
  590.         if (event.target == ButtonStar && event.id == Event.ACTION_EVENT)
  591.         {
  592.             ButtonStar_Action(event);
  593.             return true;
  594.         }
  595.         if (event.target == ButtonCursor && event.id == Event.ACTION_EVENT)
  596.         {
  597.             ButtonCursor_Action(event);
  598.             return true;
  599.         }
  600.         if (event.target == ButtonFindDrawings && event.id == Event.ACTION_EVENT)
  601.         {
  602.             ButtonFindDrawings_Clicked(event);
  603.             return true;
  604.         }
  605.         if (event.target == ComboBoxDrawings && event.id == Event.ACTION_EVENT)
  606.         {
  607.             ComboBoxDrawings_Selected(event);
  608.             return true;
  609.         }
  610.  
  611.         if (event.target == verticalScrollbar && event.id == Event.SCROLL_LINE_UP)
  612.         {
  613.             verticalScrollbar_ScrollLineUp(event);
  614.             return true;
  615.         }
  616.  
  617.         if (event.target == verticalScrollbar && event.id == Event.SCROLL_LINE_DOWN)
  618.         {
  619.             verticalScrollbar_ScrollLineDown(event);
  620.             return true;
  621.         }
  622.  
  623.         if (event.target == verticalScrollbar && event.id == Event.SCROLL_PAGE_UP)
  624.         {
  625.             verticalScrollbar_ScrollPageUp(event);
  626.             return true;
  627.         }
  628.  
  629.         if (event.target == verticalScrollbar && event.id == Event.SCROLL_PAGE_DOWN)
  630.         {
  631.             verticalScrollbar_ScrollPageDown(event);
  632.             return true;
  633.         }
  634.  
  635.  
  636.         if (event.target == horizontalScrollbar && event.id == Event.SCROLL_LINE_UP)
  637.         {
  638.             horizontalScrollbar_ScrollLineUp(event);
  639.             return true;
  640.         }
  641.  
  642.         if (event.target == horizontalScrollbar && event.id == Event.SCROLL_LINE_DOWN)
  643.         {
  644.             horizontalScrollbar_ScrollLineDown(event);
  645.             return true;
  646.         }
  647.  
  648.         if (event.target == horizontalScrollbar && event.id == Event.SCROLL_PAGE_UP)
  649.         {
  650.             horizontalScrollbar_ScrollPageUp(event);
  651.             return true;
  652.         }
  653.  
  654.         if (event.target == horizontalScrollbar && event.id == Event.SCROLL_PAGE_DOWN)
  655.         {
  656.             horizontalScrollbar_ScrollPageDown(event);
  657.             return true;
  658.         }
  659.  
  660.         return super.handleEvent(event);
  661.     }
  662.  
  663.  
  664.     // Applet info
  665.     public String getAppletInfo()
  666.     {
  667.         return "Name: SDKDemo\r\n" +
  668.                "Author: Rob Mayfield, IMSI @1997\r\n" +
  669.                "ImageButton by Symantec Corp.\r\n" +
  670.                "Ole and COM implemented by Microsoft Corp.\r\n" +
  671.                "";
  672.     }
  673.  
  674.     public void destroy()
  675.     {
  676.         // Set all vars to null to make sure that the reference counts are decremented
  677.         // to release server application
  678.         
  679.         if (theDrawingCanvas.m_IDrawings != null)
  680.            theDrawingCanvas.m_IDrawings.Close();  // close any open TC file
  681.  
  682.         // it is good practice to release the obtained interfaces in reverse or
  683.         // to how they were obtained, although for Java, that is up to the virual
  684.         // machines garbage collection.
  685.            theDrawingCanvas.m_ITheView = null;
  686.         theDrawingCanvas.m_IViews = null;
  687.         theDrawingCanvas.m_ITheDrawing = null;
  688.         theDrawingCanvas.m_IDrawings = null;
  689.         theDrawingCanvas.m_IApp = null;
  690.  
  691.     }
  692.  
  693.     public void paint(java.awt.Graphics g)
  694.     {
  695.         // draw a 3D border around screen and Drawing area. Shows 3D in all environments
  696.         theDrawingCanvas.reshape(7,68, bounds().width - 28, bounds().height - 108);
  697.         StatusBox.reshape(4, theDrawingCanvas.bounds().y + theDrawingCanvas.bounds().height + 16,
  698.                             bounds().width - 8, 21);
  699.  
  700.         // reset size of scrollbar
  701.         horizontalScrollbar.reshape(bounds().width/2 - 105,
  702.             theDrawingCanvas.bounds().y + theDrawingCanvas.bounds().height + 1 ,210, 16);
  703.         verticalScrollbar.reshape(bounds().width - 20,
  704.             theDrawingCanvas.bounds().y + (theDrawingCanvas.bounds().height/2) - 99, 16, 198);
  705.         
  706.         // draw a quick and dirty 3D border around edge of frame
  707.         Rectangle rec = this.bounds();
  708.         g.setColor(Color.white);
  709.         g.drawRect(0, 0, rec.width-3, rec.height-3);
  710.         g.drawRect(0, 0, rec.width-2, rec.height-2);
  711.         g.setColor(Color.darkGray);
  712.         g.drawRect(2, 2, rec.width-3, rec.height-3);
  713.  
  714.         g.setColor(Color.darkGray);
  715.         g.draw3DRect(5, 66, bounds().width - 26, bounds().height - 105, false);
  716.  
  717.     }
  718.  
  719.     public void start()
  720.     {
  721.     }
  722.     
  723.     public void stop()
  724.     {
  725.  
  726.     }
  727.  
  728.     private boolean m_fStandAlone = false;
  729.  
  730.     String fName;  // file name
  731.     public static SDKDemoFrame frame;
  732.  
  733.     String docBase = null;
  734.  
  735.     //symantec.itools.awt.ImageButton ButtonCursor;
  736.     mImageButton ButtonCursor;
  737.     mImageButton ButtonStar;
  738.     mImageButton ButtonSpline;
  739.     mImageButton ButtonLine;
  740.     mImageButton ButtonCircle;
  741.  
  742.     java.awt.Button ButtonProperties;
  743.     java.awt.Button ButtonNew;
  744.     java.awt.Button ButtonZoomPlus;
  745.     java.awt.Button ButtonZoomMinus;
  746.     java.awt.Button ButtonFindDrawings;
  747.     java.awt.TextField StatusBox;
  748.     java.awt.Choice ComboBoxDrawings;
  749.     
  750.     // the DrawingCanvas is a subclass of Canvas and contains all the IMSI SDK actions
  751.     DrawingCanvas theDrawingCanvas;    
  752.     java.awt.Scrollbar horizontalScrollbar;
  753.     java.awt.Scrollbar verticalScrollbar;
  754.  
  755.     // Constants used to distinguise actions in DrawingCanvas
  756.     public static final int NONECLICK = 0;
  757.     public static final int CIRCLECLICK = 1;
  758.     public static final int LINECLICK = 2;
  759.     public static final int SPLINECLICK = 3;
  760.     public static final int STARCLICK = 4;
  761.     public static final int PICKCLICK = 5;
  762.  
  763.     public static final int ZOOMMINUSCLICK = 6;
  764.     public static final int ZOOMPLUSCLICK = 7;
  765.     public static final int NEWCLICK = 8;
  766.     public static final int FILELOADCLICK = 9;
  767.  
  768.     public static final int HORZSCROLLDOWN = 10;
  769.     public static final int HORZSCROLLPGDN = 11;
  770.     public static final int VERTSCROLLDOWN = 12;
  771.     public static final int VERTSCROLLPGDN = 13;
  772.  
  773.     public static final int HORZSCROLLUP = 14;
  774.     public static final int HORZSCROLLPGUP = 15;
  775.     public static final int VERTSCROLLUP = 16;
  776.     public static final int VERTSCROLLPGUP = 17;
  777.     public static final int THUMB_MOVE = 18;
  778.  
  779. }
  780.